package model.financial;

import model.person.Person;

public class Bill {

	BillState billOpen;
	BillState billPayed;
	BillState billSent;
	BillState billArchived;

	private float amount;
	private String timestamp;
	private Person person;

	private BillState state = billOpen;

	public Bill(float amount, String date, Person person) {
		this.amount = amount;
		this.timestamp = date;
		this.person = person;

		billOpen = new BillOpen(this);
		billPayed = new BillPayed(this);
		billSent = new BillSent(this);
		billArchived = new BillArchived(this);
	}

	public void handleBill() throws Exception {
		this.state.handle();
	}

	public void archiveBill() throws Exception {
		this.state.archive();
	}

	public float getAmount() {
		return amount;
	}

	public void setAmount(float amount) {
		this.amount = amount;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public String getStateString() {
		if (state instanceof BillOpen) {
			return "Open";
		} else if (state instanceof BillSent) {
			return "Sent";
		} else if (state instanceof BillPayed) {
			return "Payed";
		} else if (state instanceof BillArchived) {
			return "Archived";
		}
		return null;
	}

	public BillState getBillOpen() {
		return billOpen;
	}

	public BillState getBillSent() {
		return billSent;
	}

	public BillState getBillPayed() {
		return billPayed;
	}

	public BillState getBillArchived() {
		return billArchived;
	}

	public void setState(BillState billState) {
		this.state = billState;
	}

}
